home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / ACL / Animation Class Library / Headers / AnimGfx.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-01  |  3.5 KB  |  118 lines  |  [TEXT/MPCC]

  1.  
  2. /********************************************
  3.  **** Animation Class Library V1.0 © 1994 Yves Schmid & Alia Development
  4.  ****
  5.  **** AnimGfx.h
  6.  ****
  7.  **** Created:      10 April 1994
  8.  **** Modified:     01 Septembre 1994
  9.  **** Version:      0
  10.  **** Compatible:   C++, Mac System 7
  11.  ****
  12.  **** Description:  • AnimGfx is a simple class which handles an image in memory. AnimGfx
  13.  ****                is very fast because it does not work with pictures but only with
  14.  ****                pixmaps. 
  15.  ****
  16.  ****                • AnimGfx is a child class of CoreHead.
  17.  ****
  18.  *******************/
  19.  
  20.  
  21.  
  22. #ifndef ANIMGFX_H
  23. #define ANIMGFX_H
  24.  
  25. #include <QDOffscreen.h>
  26.  
  27. #include "CoreHead.h"
  28.  
  29. class AnimGfx : public CoreHead
  30. {
  31.  
  32.     //***********************************************************
  33.     //.............. P U B L I C   M E T H O D S.................
  34.  
  35.     public:
  36.     
  37.     AnimGfx();
  38.     AnimGfx(CoreHead *supervisor, long entry =0);    // If you want to link your object
  39.                                                     // to a supervisor (see CoreClass).
  40.     
  41.     ~AnimGfx();
  42.     
  43.     // This methods allow you get pointers on the PixMap or the GWorld. They may return NULL if
  44.     // the object is empty (if it does not contains an image).
  45.     
  46.     inline PixMapHandle getpixmap(void) const {return (gworld)?GetGWorldPixMap(gworld):NULL;}
  47.     inline GWorldPtr getgworld(void) const {return gworld;}
  48.  
  49.  
  50.     virtual void purge(void);    // Frees the current image. The object becomes empty.
  51.     
  52.  
  53.     short getwidth(void) const;        // Returns the size of the picture, return -1 if
  54.     short getheight(void) const;    // object is empty.
  55.  
  56.     virtual void createbypict(PicHandle pict);              // Creates with a Picture handle
  57.     virtual void createbypict(long pictres);             // Creates with a Picture resource
  58.     virtual void create(short width, short height);        // Creates an empty pixmap
  59.     
  60.     virtual PicHandle createpict(void);    // Creates a picture handle, copies the contains of the
  61.                                           // internal pixmap into the picture and returns the
  62.                                         // picture handle. It's up to you to free the pichandle
  63.                                       // when you don't need it anymore.
  64.                                 
  65.  
  66.     virtual void createmaskrgb(RGBColor *rgb =NULL);
  67.                             // Creates a mask using by default the white color to
  68.                            // fill the mask with zero bits. You can override this by giving 
  69.                           // a RGBColor to "createmaskrgb".
  70.                                                         
  71.     virtual void freemask(void);
  72.  
  73.     inline BitMap *getmask(void) {return mask;}    // Returns mask or NULL
  74.  
  75.     inline unsigned long *getlinemask(void) {return linemask;}    // Returns linemask or NULL.
  76.                                                                 // A linemask is a one line mask
  77.                                                                 // where all lines of the
  78.                                                                 // principal mask have been ORed.
  79.                                                                 // Useful for fast collision checking.
  80.  
  81.  
  82.     virtual void draw(short x, short y, short tmode =srcCopy);    // Draws the full object
  83.     
  84.     virtual void drawrect(Rect scr, short x, short y, short tmode =srcCopy); // Draws part of the object
  85.                 
  86.     virtual void drawrect(Rect scr, Rect dest, short tmode =srcCopy); // Draws part of the object with
  87.                                                                       // a scale to fit into the dest rect
  88.  
  89.     virtual void drawrect(Rect dest, short tmode =srcCopy);  // Draws the full object with a scale
  90.                                                             // to fit into the dest rect
  91.  
  92.  
  93.     virtual void setport(void);            // The pixmap becomes the current port
  94.     virtual void restoreport(void);       // Restores the old port. Must be called after a setport!
  95.  
  96.  
  97.     unsigned long userdata;        // Use this variable like you want
  98.  
  99.  
  100.  
  101.  
  102.     //***********************************************************
  103.  
  104.     private:
  105.  
  106.     GWorldPtr        gworld;            // private section
  107.     BitMap            *mask;
  108.     unsigned long    *linemask;        
  109.     
  110.     CGrafPtr        oldport;
  111.     GDHandle        olddevice;
  112.     
  113. };
  114.  
  115. #endif
  116.  
  117.  
  118.